package com.zhkj.txg.module.home.model

import com.zhkj.lib.http.BaseApiService
import com.zhkj.lib.http.BaseResponse
import com.zhkj.txg.module.cart.entity.CartResponse
import com.zhkj.txg.module.home.entity.*
import io.reactivex.Observable
import retrofit2.http.*

interface HomeApi : BaseApiService {

//    @GET("api/index/index")
//    fun homeData(@Query("token") token: String): Observable<HomeResponse>

    @GET("api/index/index")
    fun homeData(@QueryMap map: Map<String, String>?): Observable<HomeResponse>

    @FormUrlEncoded
    @POST("api/shops/shop_list")
    fun getShopList(@FieldMap map: Map<String, String>?): Observable<ShopListResponse>
//    fun getShopList(@QueryMap map: Map<String, String>): Observable<HomeResponse>

    @GET("api/index/hotGoods")
    fun hotGoods(
        @Query("token") token: String,
        @Query("page") page: Int,
        @Query("rows") numb: Int
    ): Observable<HotGoodsResponse>

    @GET("api/index/sharpGoods")
    fun topData(@Query("token") token: String): Observable<TopDataResponse>

    @GET("api/index/sharpHotGoods")
    fun topProduct(
        @Query("token") token: String,
        @Query("page") page: Int,
        @Query("rows") rows: Int
    ): Observable<TopProductResponse>

    @GET("api/index/supermarket")
    fun marketData(@Query("token") token: String): Observable<TopDataResponse>

    @GET("api/index/smHotGoods")
    fun marketProduct(
        @Query("token") token: String,
        @Query("page") page: Int,
        @Query("rows") rows: Int
    ): Observable<TopProductResponse>

    @GET("api/index/smCategory")
    fun marketCate(
        @Query("token") token: String,
        @Query("cat_id") catId: Int
    ): Observable<MarketCateResponse>

    @GET("api/goods/secondCategory")
    fun secondCate(
        @Query("token") token: String,
        @Query("cat_id") catId: Int
    ): Observable<MarketCateResponse>

    @FormUrlEncoded
    @POST("api/goods/goodsList")
    fun searchProductList(
        @Field("token") token: String,
        @Field("shop_id") ShopId: Int,//门店id
        @Field("active_type") activeType: Int?,//活动类型 0普通商品 1限时促销 2预售
        @Field("search") search: String?,//搜索关键词
        @Field("cat_id") catId: Int?,//分类id
        @Field("sort") sort: String?,//排序类型 ‘sales_sum’,’price’,’weigh’
        @Field("sort_asc") sortAsc: String?,//排序
        @Field("page") page: String,//分页
        @Field("rows") rows: String,//每页显示记录数
        @Field("recommend") recommend: Int?//是否推荐(0=无推荐,1=推荐,不填=全部)
    ): Observable<SearchProductResponse>

//    @GET("api/goods/goodsList")
//    fun searchProductList(
//        @Query("token") token: String,
//        @Query("shop_id") ShopId: Int,
//        @Query("cat_id") catId: Int,
//        @Query("shop_cat_id") shopCatId: Int,
//        @Query("sort") sort: String,// 排序类型 默认weigh综合 sales_sum 销量 price价格
//        @Query("sort_asc") asc: String,// 排序方式 默认desc 降序 asc 升序
//        @Query("type") type: Int,// 类型 云集超市/尖货搜索时必传 0商城 1超市 2尖货
//        @Query("search") searchKey: String,
//        @Query("page") page: Int,
//        @Query("rows") rows: Int
//    ): Observable<SearchProductResponse>

    @GET("api/goods/categoryList")
    fun categoryAll(): Observable<CategoryAllResponse>

    @GET("api/index/mall")
    fun mallData(@Query("token") token: String): Observable<MallResponse>

    @GET("api/index/mallRecommendShops")
    fun mallShopList(
        @Query("token") token: String,
        @Query("page") page: Int,
        @Query("rows") rows: Int
    ): Observable<MallShopResponse>

    @GET("api/index/mallCategory")
    fun mallCategory(
        @Query("token") token: String,
        @Query("cat_id") catId: Int,
        @Query("type") type: Int,// 类型 0品牌一览 1商品推荐
        @Query("page") page: Int,
        @Query("rows") rows: Int
    ): Observable<MallCategoryResponse>

    @GET("api/shops/index")
    fun shopDetail(
        @Query("token") token: String,
        @Query("shop_id") shopId: Int
    ): Observable<ShopResponse>

    @FormUrlEncoded
    @POST("api/shops/collect")
    fun followShop(
        @Field("token") token: String,
        @Field("shop_id") shopId: Int
    ): Observable<ShopFollowResponse>

    @GET("api/shops/categoryList")
    fun shopCate(@Query("shop_id") shopId: Int): Observable<ShopCategoryResponse>

    @FormUrlEncoded
    @POST("api/shops/apply")
    fun merchantRegister(
        @Field("token") token: String,
        @Field("name") name: String,
        @Field("gender") gender: Int,
        @Field("age") age: String,
        @Field("mobile") mobile: String,
        @Field("apply_desc") reason: String,
        @Field("businessicence_img") license: String,
        @Field("card_front_img") identifyFront: String,
        @Field("card_back_img") identifyBack: String
    ): Observable<BaseResponse>

    @GET("api/welfare/index")
    fun welfare(): Observable<WelfareResponse>

    @GET("api/common/sysConfig")
    fun getConfig(): Observable<ConfigResponse>

    @GET("api/common/getVersion")
    fun getVersion(): Observable<VersionResponse>

    @GET("api/article/detail")
    fun guideDetail(@Query("id") id: Long): Observable<GuideDetailResponse>

    @GET("api/goods/shareInfo")
    fun shareInfo(@Query("token") token: String, @Query("id") id: Long): Observable<ShareInfoResponse>

    @GET("api/shops/checkApply")
    fun isUserApply(@Query("token") token: String): Observable<ApplyResponse>

    @FormUrlEncoded
    @POST("api/user/bindChatId")
    fun bindChatId(@Field("token") token: String, @Field("chat_id") chatId: String): Observable<BaseResponse>


    @FormUrlEncoded
    @POST("api/cart/add")
    fun addCart(@FieldMap map: Map<String, String>): Observable<BaseResponse>

    @GET("api/cart/index")
    fun getCartNew(@QueryMap map: Map<String, String>): Observable<CartResponse>


    @FormUrlEncoded
    @POST("api/goods/goodsActivity")
    fun getGoodsActivity(@Field("token") token: String, @Field("id") id: Int): Observable<EventResponse>

}